package org.andcool.animation.ease;

/**
 * @author Joosun
 * @since 2011-5-8
 */
public class EaseCircular extends BaseEase
{
	public EaseCircular(final EasingMode pEasingMode)
	{
		super(pEasingMode);
	}

	@Override
	protected float getEaseInInterpolation(final float pPercentage)
	{
		return (float) -(Math.sqrt(1 - pPercentage * pPercentage) - 1);
	}

	@Override
	protected float getEaseOutInterpolation(float pPercentage)
	{
		return (float) Math.sqrt(1 - (pPercentage -= 1) * pPercentage);
	}

	@Override
	protected float getEaseInOutInterpolation(float pPercentage)
	{
		pPercentage *= 2;

		if (pPercentage < 1)
		{
			return (float) (-0.5f * (Math.sqrt(1 - pPercentage * pPercentage) - 1));
		}
		else
		{
			return (float) (0.5f * (Math.sqrt(1 - (pPercentage -= 2) * pPercentage) + 1));
		}
	}
}